﻿using System.Windows;
using System.Windows.Input;

namespace LFSRecord2.View.Dialogs
{
    /// <summary>
    /// Interaction logic for EditDoubleValueDialogBox.xaml
    /// </summary>
    public partial class EditDoubleValueDialogBox : Window
    {
        public EditDoubleValueDialogBox()
        {
            InitializeComponent();
        }

        void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            // Dialog box canceled
            this.DialogResult = false;
        }

        void okButton_Click(object sender, RoutedEventArgs e)
        {
            // Don't accept the dialog box if there is invalid data - we use our own check for this (less code), skipping the default validation rules
            double newValue = 0;
            if (!double.TryParse(doubleValue.Text, out newValue))
            {
                Keyboard.Focus(doubleValue);
                return;
            }

            // Dialog box accepted
            this.DialogResult = true;
        }
    }
}
